/**  
  -- The Performance Driven Lime Project -- 

  A self adaptive tuple space for mobile agents and hosts by dynamic
  adapting tuple's replication policy.
  
  Copyright (C) 2008
  Xing Jiankuan, Pan Wenhui
  SAGroup of Tsinghua University

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  Lesser General Public License for more details.

  You should have received this copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
 */
package sagroup.dracots.commands;

import lime2.Location;
import lime2.TupleID;
import sagroup.dracots.DracoConstants;
import sagroup.dracots.Field;
import sagroup.dracots.SignalTuple;
import sagroup.dracots.SystemTupleType;

/**
 * @author Xing Jiankuan
 *
 */
public class AddReplicaRequestByEntryCommand extends SignalTuple{

	private static final long serialVersionUID = -8078070503564468513L;

	public AddReplicaRequestByEntryCommand() {
		//empty constructor
	}
	
	public AddReplicaRequestByEntryCommand(ReplicaRequestEntry[] entries, Location dst) {
		super(SystemTupleType.COMMAND, dst);
		this.entries = entries;
	}
	
	@Field
	private ReplicaRequestEntry[] entries;
	
	public ReplicaRequestEntry[] getEntries() {
		return entries;
	}
	
	@SuppressWarnings("serial")
	public static class ReplicaRequestEntry implements java.io.Serializable {
		public ReplicaRequestEntry() { /* empty constructor */
		}

		/**
		 * Constructor for entry
		 * 
		 * @param vid
		 *            the tuple's vid whose replica is added
		 * @param ev
		 *            expected version
		 */
		public ReplicaRequestEntry(TupleID vid, Long ev) {
			this.vid = vid;
			this.ev = ev; 
		}

		/**
		 * Constructor for entry, not specified expected version. and expected
		 * version would be set DracoConstants.INVALID_VER_NUM
		 * 
		 * @param vid
		 *            the tuple's vid whose replica is added
		 */
		public ReplicaRequestEntry(TupleID vid) {
			this(vid, DracoConstants.INVALID_VER_NUM);
		}

		/**
		 * VID of target tuple
		 */
		public TupleID vid;
		/**
		 * expected version
		 */
		public Long ev;
	}
}
